import {Module, ActionContext} from 'vuex';
import Ajax from '@/lib/ajax';

interface SettingState {
    setting: any,
}

class SettingModule implements Module<SettingState, any> {
    namespaced = true;
    state = {
        setting: {},
    };
    actions = {
        async getAllSettings(context: ActionContext<SettingState, any>, payload: any) {
            const response = await Ajax.get('/api/services/app/HostSettings/GetAllSettings');
            context.state.setting = response.data.result;
        },
        async updateAllSettings(context: ActionContext<SettingState, any>, payload: any) {
            await Ajax.put('/api/services/app/HostSettings/UpdateAllSettings', payload.data);
        },
    };
}

const settingModule = new SettingModule();
export default settingModule;
